package org.starapp.rbac.entity;

import javax.persistence.GenerationType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author wangqiang@cisoft.com.cn
 *
 */
@Entity
@Table(name = "rbac_operations")
public class Operations implements Serializable{
		
				
		/**
		 * OPERATION_ID
		 */
		private String operationId;
				
		/**
		 * OPERATION_NAME
		 */
		private String operationName;
		
		

		private List<Objects> objectsM2MList;				

		private List<Permissons> permissonsList;				

		
				
		@Id
		@Column(name="OPERATION_ID")
		@NotBlank
		public String getOperationId(){
			return this.operationId;
		}
		
		public void setOperationId(String operationId){
			this.operationId = operationId;
		}
		
				
		@NotBlank
		public String getOperationName(){
			return this.operationName;
		}
		
		public void setOperationName(String operationName){
			this.operationName = operationName;
		}
		
		
				
		@ManyToMany
		@JoinTable(name = "rbac_objects_operations", joinColumns={@JoinColumn(name="OPERATION_ID") },inverseJoinColumns={@JoinColumn(name="OBJECT_ID")})		
		public List<Objects> getObjectsM2MList(){
			return this.objectsM2MList;
		}
		
		public void setObjectsM2MList(List<Objects> objectsM2MList){
			this.objectsM2MList = objectsM2MList;
		}
				
		@OneToMany(mappedBy = "operations")
		public List<Permissons> getPermissonsList(){
			return this.permissonsList;
		}
		
		public void setPermissonsList(List<Permissons> permissonsList){
			this.permissonsList = permissonsList;
		}

		
		@Override
		public String toString() {
			return ToStringBuilder.reflectionToString(this);
		}
	
	}

